<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.4/jquery.js"></script>
    
    <title>Document</title>

    <script>
        $(() => {
        $("#btn1").click(function(){
            //将选中添加到右边
            $("select[name=sel01] option:selected").appendTo( $("select[name=sel02]"))
        })
        $("#btn2").click(function(){
            //全部添加到右边 
            $("select[name=sel01] option").appendTo( $("select[name=sel02]"))
        })
        $("#btn3").click(function(){
            //选中删除到左边
            $("select[name=sel02] option:selected").appendTo($("select[name=sel01]"))
        })
        $("#btn4").click(function(){
            //全部删除到左边
            $("select[name=sel02] option").appendTo($("select[name=sel01]"))
        })
    })
    </script>
    <style type="text/css">
        select {
          width: 100px;
          height: 140px;
        }
        div {
          width: 130px;
          float: left;
          text-align: center;
        }
      </style>
</head>
<body>
    <div id="left">
        <select multiple="multiple" name="sel01">
          <option value="opt01">选项 1</option>
          <option value="opt02">选项 2</option>
          <option value="opt03">选项 3</option>
          <option value="opt04">选项 4</option>
          <option value="opt05">选项 5</option>
          <option value="opt06">选项 6</option>
          <option value="opt07">选项 7</option>
          <option value="opt08">选项 8</option>
        </select>
        <button id="btn1">将选中添加到右边</button>
        <button id="btn2">全部添加到右边</button>
      </div>
      <div id="rigth">
        <select multiple="multiple" name="sel02"></select>
        <button id="btn3">选中删除到左边</button>
        <button id="btn4">全部删除到左边</button>
      </div>
</body>
</html>